package day9;

import java.util.Arrays;

public class Demo2 {
    public static void main(String[] args) {
        String s = "java";//指向常量池
        String s2 = new String("java");//指向堆内存
        String s3 = new String("java");//指向堆内存
        String s4 = "java";   //常量池不能重复
        //==是判断引用地址是否一致
        System.out.println(s==s4);
        //equals判断内容是否一致
        System.out.println(s.equals(s2));

        String s5 = "java代码";
        System.out.println(s5.length());
        //统计字节  就不是6  每种编码方式所占字节不同
        //GBK 2
        //utf-8  3
        //String--->char数组
        char[] cs=s5.toCharArray();
        //String --->byte数组
        byte[] bs=s5.getBytes();
        System.out.println(Arrays.toString(cs));
        System.out.println(Arrays.toString(bs));
    }
}
